import { removeCookie } from '@/utils/cookie';
import { useModel, useNavigate } from '@umijs/max';
import { Button, message } from 'antd';

const Header = () => {
  const { saveToken } = useModel('tokenModel');
  const navigate = useNavigate();

  const useLogout = () => {
    message.open({
      type: 'success',
      content: '退出成功',
      duration: 1.5,
      onClose: () => {
        saveToken('');
        removeCookie('token');
        navigate('/login');
      },
    });
  };

  return <Button onClick={useLogout}>退出</Button>;
};

export default Header;
